﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DIPPrinciple.NewDesign
{
    public class Button
    {
        private readonly ISwitchableDevice _switchableDevice;
        private bool _isDown;
        public Button(ISwitchableDevice switchableDevice)
        {
            _switchableDevice = switchableDevice;
            _isDown = false;
        }

        public void Click()
        {
            if (_isDown)
            {
                _switchableDevice.TurnOn();
            }
            else
            {
                _switchableDevice.TurnOff();
            }
        }
    }
}
